<template>
  <!-- 控制台页面 -->
  <basemainslot>
    <template v-slot:content>
      <div class="controlview-hearder">
        <div class="header-line-top">用户基本信息</div>
        <div class="header-line-main">
          <div class="header-line-one-zh">
            <div class="zh-custom">
              <i class="el-icon-s-custom"></i>
            </div>
            <!-- <div>管理员,您好!</div> -->
          </div>
          <div class="header-line-right">
            <div class="header-line-zh">
              <div style="white-space: nowrap; width: 120px">当前种养批次：</div>
              <div class="betterline">
                <div v-for="(item, index) in allBatchList" :key="index" class="header-line-zh-item">
                  <!-- <i v-if="(index+0)%2">、</i> -->
                  {{ item.batchName }}
                </div>
              </div>
              <!-- <div class="addfarmcompany" @click="shengqingjidi()"></div> -->
            </div>
            <div class="header-line-zh" style="margin-top: 0px">
              <div style="display: flex; align-items: center">
                <div style="white-space: nowrap; width: 120px">当前种养品种：</div>
                <div class="betterline" style="margin-bottom: 10px">
                  <div
                    v-for="(item, index) in allplanttypeone"
                    :key="index"
                    class="header-line-zh-item"
                  >
                    <!-- <i v-if="(index+0)%2">、</i> -->
                    <!-- {{ item.plantingTypeName }} - {{ item.varietyName }} -->
                    {{ item }}
                  </div>
                </div>
              </div>
              <div style="border-left: #fff 3px solid; padding-left: 5px;display: flex;">
                <div style="white-space: nowrap; width: 120px">种养总面积：</div>
                <div class="header-line-zh-item">
                  {{ totalArea }}
                  亩
                </div>
              </div>
              <div v-if="isshowgrowmode" class="zhgrowthbut" @click="tomgrowthodel()">查看作物生长模型</div>
            </div>
          </div>
        </div>
      </div>
      <div class="controlview-main-one">
        <div class="main-one-left">
          <div class="one-left">
            <div
              id="task-message-notification"
              class="one-left-title"
              @click="toLocal('task-message-notification')"
            >任务消息通知</div>
            <div class="one-left-menu">
              <div v-for="(item, index) in notagriculturalTask" :key="index" class="left-menu-item">
                <div @click="routerTo(1)">
                  <div class="menu-item-title">
                    <span style="color:#ffe400">•</span> 任务处理提醒
                  </div>
                  <div
                    class="menu-item-message"
                  >您有一个{{ item.agriculturalWorkType.agriculturalWorkTypeName }}任务{{ item.result }}。 {{ item.execEndTime }}</div>
                </div>
              </div>
              <div v-if="alarmtasknum >= 0" class="left-menu-item">
                <div @click="routerTo(1)">
                  <div class="menu-item-title-two">
                    <span style="color:#ffe400">•</span> 任务处理提醒
                  </div>
                  <div class="menu-item-message">
                    您有
                    {{ notagriculturalTask?notagriculturalTask.length:0 }}
                    个任务待处理。
                    {{ dateToFormat(new Date()) }}
                  </div>
                </div>
              </div>
            </div>
          </div>
          <div class="one-left">
            <div class="one-left-title">告警消息通知</div>
            <div class="one-left-menu">
              <div v-for="(item, index) in notalarmmessage" :key="index" class="left-menu-item">
                <div @click="routerTo(2)">
                  <div class="menu-item-title">
                    <span style="color:#ffe400">•</span> 告警信息
                  </div>
                  <div class="menu-item-message">{{ item.message }}</div>
                </div>
              </div>
            </div>
          </div>
          <!-- <div class="controlview-main-one"> -->
          <!-- <div class="main-one-left"> -->

          <!-- <div v-if="alarmtasknum >= 0" class="left-menu-item">
              <div :to="{ path: '/agricultural-task-processing' }">
                <div class="menu-item-title-two">· 任务处理提醒</div>
                <div class="menu-item-message">
                  您有
                  {{ alarmtasknum }}
                  个任务待处理。
                  {{ dateToFormat(new Date()) }}
                </div>
              </div>
          </div>-->
        </div>
        <!-- </div> -->
        <div class="main-one-right">
          <div class="one-right-line">
            <div class="right-line-title">近30天任务情况分析</div>
            <div class="right-line-main">
              <template v-for="(zztaskitem, zztaskindex) in nowMonthTasklist">
                <div
                  v-if="zztaskitem.result !== '已作废'"
                  :key="zztaskindex"
                  class="line-main-one zh-back"
                  :class="
                    zztaskitem.result === '待处理'
                      ? 'zh-back'
                      : zztaskitem.result === '已完成'
                        ? 'zh-backtwo'
                        : 'zh-backthree'
                  "
                >
                  <div class="line-main-one-title">{{ zztaskitem.result }}任务</div>
                  <div class="line-main-one-message">{{ zztaskitem.number }}</div>
                </div>
              </template>
            </div>
            <div class="zh-pie">
              <lineechart
                :cdata="cdatathree"
                :nowwidth="'100%'"
                :nowheight="'100%'"
                :isshowleg="true"
                :font-size="15"
              />
            </div>
          </div>
          <div class="one-right-line">
            <div class="right-line-title">近30天告警情况分析</div>
            <div class="right-line-main">
              <div class="line-main-one zh-back">
                <div class="line-main-one-title">总告警次数:</div>
                <div class="line-main-one-message">{{ nowdatalist.completed + nowdatalist.pending }}</div>
              </div>
              <div class="line-main-one zh-back">
                <div class="line-main-one-title">已处理告警:</div>
                <div class="line-main-one-message">{{ nowdatalist.completed }}</div>
              </div>
              <div class="line-main-one zh-backtwo">
                <div class="line-main-one-title">待处理告警:</div>
                <div class="line-main-one-message">{{ nowdatalist.pending }}</div>
              </div>
              <!-- <div class="line-main-one zh-backthree">
                <div class="line-main-one-title">已逾期告警:</div>
                <div class="line-main-one-message">
                  {{ nowdatalist.overdue }}
                </div>
              </div>-->
            </div>
            <div class="zh-pie">
              <!-- <piechart
                :cdata="nowMonthTaskPietwo"
                :nowwidth="'300px'"
                :nowheight="'200px'"
              />-->
              <lineechart
                :cdata="cdatatwo"
                :nowwidth="'100%'"
                :nowheight="'100%'"
                :isshowleg="true"
                :font-size="15"
              />
            </div>
          </div>
        </div>
      </div>
      <div v-if="false" class="controlview-main-two">
        <div class="controlview-main-two-hearder">
          <div class="main-two-hearder-title">批次告警次数</div>
          <div class="main-two-hearder-right" @click="dialogVisible = true">详细信息</div>
        </div>
        <div class="main-two-echart-line">
          <barchart :cdata="batchLineChart" :nowwidth="'100%'" :nowheight="'160px'" />
        </div>
      </div>
      <!-- <div style="height:20px;"></div> -->
      <div class="controlview-main-two">
        <div class="controlview-main-two-hearder">
          <div class="main-two-hearder-title">料肥统计信息({{ liaofeitotal }}条)</div>
          <div style="display: flex; justify-content: center;align-items: center;">
            <div style="margin-right:5px;margin-top: 3px">
              第
              <el-input v-model.number="liaofeipage" class="liaoinput" @input="liaofeiPasz" />
              页
              共 {{ liaototalPages }} 页
              共 {{ liaofeitotal }} 条
            </div>
            <div
              class="main-two-hearder-right"
              style="margin-right: 10px;"
              @click="jianliaofeipage()"
            >上一页</div>
            <div class="main-two-hearder-right" @click="addliaofeipage()">下一页</div>
          </div>
        </div>
        <div class="main-two-table-line">
          <el-table highlight-current-row :data="liaofeitableData" stripe border height="95%">
            <el-table-column type="index" label="序号" width="50" />
            <el-table-column prop="materialDTO.materialTypeName" label="药肥种类" />
            <el-table-column prop="productionBatchBO.batchName" label="投入批次" min-width="150" />
            <!-- <el-table-column prop="facilityVOList" label="投入设施">
          <template slot-scope="scope">
            <div
              v-for="item in scope.row.facilityVOList"
              :key="item.facilityNo"
            >
              {{ item.facilityName }}
            </div>
          </template>
            </el-table-column>-->
            <el-table-column prop="personName" label="经手人" />
            <el-table-column prop="assetQuantity" label="总投入量">
              <template v-if="scope.row.assetQuantity" slot-scope="scope">
                <div v-if="scope.row.average">{{ scope.row.assetQuantity }}{{ scope.row.unitName }}</div>
                <div v-else>—</div>
              </template>
            </el-table-column>
            <el-table-column prop="average" label="亩均用量">
              <template v-if="scope.row.average" slot-scope="scope">
                <div v-if="scope.row.average">
                  {{ scope.row.average }}{{ scope.row.unitName }}
                  <span>/</span>
                  {{ '亩' }}
                </div>
                <div v-else>—</div>
              </template>
            </el-table-column>
            <el-table-column prop="materialDTO.ratedQuantity" label="定额用量">
              <template v-if="scope.row.materialDTO" slot-scope="scope">
                <div v-if="scope.row.materialDTO.ratedQuantity">
                  {{ scope.row.materialDTO.ratedQuantity
                  }} {{ scope.row.materialDTO.perSpecUnitName }}
                  <span>/</span>
                  {{ '亩' }}
                </div>
                <div v-else>—</div>
              </template>
            </el-table-column>
            <el-table-column label="是否超标">
              <template slot-scope="scopeone">
                <div v-if="scopeone.row.materialDTO && scopeone.row.average">
                  <div
                    v-if="
                      scopeone.row.average <=
                        scopeone.row.materialDTO.ratedQuantity
                    "
                    style="color: #12c238"
                  >正常</div>
                  <div
                    v-else-if="
                      scopeone.row.average >
                        scopeone.row.materialDTO.ratedQuantity
                    "
                    style="color: #c21e12"
                  >超标</div>
                </div>
                <div v-else-if="scopeone.row.materialDTO">—</div>
              </template>
            </el-table-column>
          </el-table>
        </div>
      </div>
      <div style="height: 20px"></div>
      <div class="controlview-main-three">
        <div style="width: 100%; display: flex; justify-content: space-between">
          <div class="main-two-yiban-box">
            <div class="main-two-hearder-title" style="margin-bottom: 38px">农事任务信息</div>
            <div>
              <zhechart
                :cdata="farmtaskcdata"
                :nowheight="'250px'"
                :nowwidth="'100%'"
                :bottom="'20'"
              />
            </div>
          </div>
          <div class="main-two-yiban-box">
            <div class="main-two-hearder-title" style="margin-bottom: 38px">农资投入信息</div>
            <zhechart
              :cdata="farmsoucerecordcdata"
              :nowheight="'250px'"
              :nowwidth="'100%'"
              :bottom="'20'"
            />
          </div>
        </div>
      </div>
      <div style="height: 20px"></div>
      <el-dialog title="批次告警信息" :visible.sync="dialogVisible" border width="60%">
        <div class="zh-table">
          <div class="zh-table-search">
            <el-date-picker
              v-model="tableSearchDateList"
              type="monthrange"
              align="right"
              unlink-panels
              range-separator="至"
              start-placeholder="开始月份"
              end-placeholder="结束月份"
              :picker-options="pickerOptions"
            />
            <div>
              <el-select v-model="nowbatchId" filterable clearable>
                <el-option
                  v-for="(item, index) in allBatchList"
                  :key="index"
                  placeholder="请选择批次"
                  :value="item.batchNo"
                  :label="item.batchName"
                />
              </el-select>
            </div>
            <div class="contrl-view-but" @click="gettablebatchList"></div>
          </div>
          <el-table :data="batchAlarmTable" style="width: 100%; height: 500px">
            <el-table-column prop="batchName" label="批次名" />
            <el-table-column prop="dataItemName" label="数据项" />
          </el-table>
        </div>
      </el-dialog>
    </template>
  </basemainslot>
</template>
<script>
import basemainslot from "@/components/BaseMainSlot/baseone.vue";
// import piechart from "@/components/Echarts/components/piechart/chart.vue";
import barchart from "@/components/Echarts/components/linechart/chart.vue";
import nowpagereq from "@/api/zh-console-view/index";
import zhechart from "@/components/Echarts/components/linechart/chart.vue";
import * as echarts from "echarts";
import lineechart from "@/components/Echarts/components/linechart/charttwo.vue";

// class Sets {
//   constructor(name) {
//     this.name = name;
//   }
//   sayHi() {
//     console.log(this.name);
//   }
// }
// let dats = new Sets(3);
// dats.sayHi();
// import danwei from "@/api/basic-info-manage/unit-manage/index";
export default {
  components: { basemainslot, barchart, zhechart, lineechart },
  data() {
    return {
      // 判断是否展示查看生长作物模型
      isshowgrowmode: false,
      alarmtasknum: "",
      allplanttypeone: [],
      // 种养总面积
      totalArea: 0,
      // 当前种养批次
      allBatchList: [
        {
          batchName: "暂无数据"
        }
      ],
      notalarmmessage: [],
      alarmmessagenumone: 0,
      alarmmessagenumtwo: 0,
      // 当月任务情况分析
      // 饼图
      nowMonthTaskPie: [
        {
          name: "当月任务情况分析",
          type: "pie",
          selectedMode: "single",
          radius: ["50%", "70%"],
          clockwise: false,
          label: {
            position: "outside",
            formatter: "{b}\n{c}条 ({d}%)",
            shadowBlur: 10,
            shadowOffsetX: 0,
            shadowColor: "rgba(0, 0, 0, 0.5)",
            color: "#FFFDFE"
          },
          data: [
            { value: 0, name: "手动作业" },
            { value: 0, name: "自动作业" }
          ]
        }
      ],
      // 数据
      // 当月告警信息分析
      // 饼图
      nowMonthTaskPietwo: [
        {
          name: "当月告警信息分析",
          type: "pie",
          selectedMode: "single",
          radius: ["50%", "70%"],
          clockwise: false,
          label: {
            position: "outside",
            formatter: "{b}\n{c}条 ({d}%)",
            color: "#FFFDFE"
          },
          data: [
            { value: 0, name: "待处理" },
            { value: 0, name: "已处理" },
            { value: 0, name: "已逾期" }
          ]
        }
      ],

      cdatatwo: {
        // xAxisdata: [],
        xData: ["待处理告警", "已处理告警"],
        // seriesData: []
        xAxisdata: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
        // xData: ["物联网数据"],
        seriesData: [
          {
            name: "待处理告警",
            type: "line",
            data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 23804],
            barWidth: 10,
            itemStyle: {
              normal: {
                barBorderRadius: 5,
                color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
                  { offset: 0, color: "#04FA99" },
                  { offset: 1, color: "#3EACE5" }
                ])
              }
            },
            z: -12
          },
          {
            name: "已处理告警",
            type: "line",
            data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            barWidth: 10,
            itemStyle: {
              normal: {
                barBorderRadius: 5,
                color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
                  { offset: 0, color: "#04FA99" },
                  { offset: 1, color: "#3EACE5" }
                ])
              }
            },
            z: -12
          }
        ]
      },
      cdatathree: {
        // xAxisdata: [],
        xData: ["待处理告警", "已处理告警"],
        // seriesData: []
        xAxisdata: ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9"],
        // xData: ["物联网数据"],
        seriesData: [
          {
            name: "待处理告警",
            type: "line",
            data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 23804],
            barWidth: 10,
            itemStyle: {
              normal: {
                barBorderRadius: 5,
                color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
                  { offset: 0, color: "#04FA99" },
                  { offset: 1, color: "#3EACE5" }
                ])
              }
            },
            z: -12
          },
          {
            name: "已处理告警",
            type: "line",
            data: [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
            barWidth: 10,
            itemStyle: {
              normal: {
                barBorderRadius: 5,
                color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
                  { offset: 0, color: "#04FA99" },
                  { offset: 1, color: "#3EACE5" }
                ])
              }
            },
            z: -12
          }
        ]
      },
      // 数据
      nowMonthTasklist: [],
      notagriculturalTask: [],
      // 批次告警次数
      // 柱状图
      batchLineChart: {
        xAxisdata: ["暂无数据"],
        xData: ["批次告警次数(次)"],
        seriesData: [
          {
            name: "批次告警次数(次)",
            type: "bar",
            data: [0],
            barWidth: 10,
            itemStyle: {
              normal: {
                barBorderRadius: 5,
                color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
                  { offset: 0, color: "#04FA99" },
                  { offset: 1, color: "#3EACE5" }
                ])
              }
            }
          }
        ]
      },
      // 料肥统计
      liaofeitableData: [],
      liaofeipage: 1,
      liaofeitotal: 0,
      liaototalPages: 0,
      nowdatalist: {},
      // 单位选择列表
      unitlist: [],
      // 农事任务信息
      farmtaskcdata: {
        xAxisdata: ["1时"],
        xData: ["农事任务信息（近七天）"],
        seriesData: [
          {
            name: "人工施用复合肥",
            type: "bar",
            data: [0],
            barWidth: 10
          },
          {
            name: "无人机打药",
            type: "bar",
            data: [0],
            barWidth: 10
          },
          {
            name: "机械施肥",
            type: "bar",
            data: [0],
            barWidth: 10
          }
        ]
      },
      // 农资投入信息
      farmsoucerecordcdata: {
        xAxisdata: [],
        xData: ["农资投入信息(近七天)"],
        seriesData: [
          {
            name: "有机肥",
            type: "bar",
            data: [],
            barWidth: 10
            // itemStyle: {
            //   normal: {
            //     barBorderRadius: 5,
            //     color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
            //       { offset: 0, color: "#04FA99" },
            //       { offset: 1, color: "#3EACE5" }
            //     ])
            //   }
            // }
          }
        ]
      },
      // 表格展示=-有时间放上
      nowbatchId: "",
      dialogVisible: false,
      tableSearchDateList: [],
      batchAlarmTable: [{ datItemName: "温度", batchName: "南梗一号" }],
      pickerOptions: {
        shortcuts: [
          {
            text: "本月",
            onClick(picker) {
              picker.$emit("pick", [new Date(), new Date()]);
            }
          },
          {
            text: "今年至今",
            onClick(picker) {
              const end = new Date();
              const start = new Date(new Date().getFullYear(), 0);
              picker.$emit("pick", [start, end]);
            }
          },
          {
            text: "最近六个月",
            onClick(picker) {
              const end = new Date();
              const start = new Date();
              start.setMonth(start.getMonth() - 6);
              picker.$emit("pick", [start, end]);
            }
          }
        ]
      }
    };
  },
  mounted() {
    this.getTotalArea();
    this.getAllBatch();
    this.getnowmonthalarmage();
    // this.getBatchAlarmNumber()
    this.getnowmonthalarmagenumber();
    this.getnowmonthfarmtaskpie();
    this.getnowmonthhandingtasknum();
    this.getoldtasklist();
    this.getliaofeitableData();
    this.getunitlist();
    this.farmtaskdataechart();
    this.farmsourceinputechart();
    this.setshowgrowmode();
    this.alarmWorkbench();
    this.agriculturalTaskbench();
    this.getnowmonthagriculturalTaskumber();
    console.log(this.set);
    // console.log("222", this.$store.state.permission.pageElementList);
  },
  methods: {
    routerTo(e) {
      if (sessionStorage.virtualSystemNo === "sc") {
        if (e === 1) {
          this.$router.push("/agricultural-task-processing");
          return "/agricultural-task-processing";
        } else if (e === 2) {
          this.$router.push("/alarm-handling");
          return "/alarm-handling";
        }
      } else {
        this.$message.warning("请前往生产管理系统查看");
      }
    },
    // 30天告警情况分析
    async alarmWorkbench() {
      let { data: data } = await nowpagereq.getWorkbenchlist();
      let dateList = [];
      if (data?.dateList.length > 0) {
        data?.dateList.forEach(item => {
          dateList.push(this.dateToFormattwo(item));
        });
      }
      let seriesData = [
        {
          name: "待处理告警",
          type: "line",
          data: data.unhandledList,
          barWidth: 10,
          itemStyle: {
            normal: {
              barBorderRadius: 5,
              color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
                { offset: 0, color: "#04FA99" },
                { offset: 1, color: "#3EACE5" }
              ])
            }
          },
          z: -12
        },
        {
          name: "已处理告警",
          type: "line",
          data: data.handleList,
          barWidth: 10,
          itemStyle: {
            normal: {
              barBorderRadius: 5,
              color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
                { offset: 0, color: "rgba(63, 168, 242, 1)" },
                { offset: 1, color: "rgba(21, 100, 232, 1)" }
              ])
            }
          },
          z: -12
        }
      ];
      this.cdatatwo = {
        xAxisdata: dateList,
        xData: ["待处理告警", "已处理告警"],
        seriesData: seriesData,
        unitName: "次",
        rightShow: false
      };
    },
    // 30天告警情况分析
    async agriculturalTaskbench() {
      let { data: data } = await nowpagereq.getagriculturalTaskbenchlist();
      let seriesData = [];
      let ColorList = [
        ["#04FA99", "#3EACE5"],
        ["rgba(63, 168, 242, 1)", "rgba(21, 100, 232, 1)"],
        ["rgba(163, 255, 224, 1)", "rgba(6, 210, 141, 1)"],
        ["rgba(255, 230, 170, 1)", "rgba(251, 177, 0, 1)"],
        ["rgba(0, 255, 255, 1)", "rgba(0, 255, 255, 1)"]
      ];
      if (data[0].length > 0) {
        data[0].forEach((item, index) => {
          seriesData.push({
            name: item,
            type: "bar",
            data: data[1][item],
            barWidth: 10,
            itemStyle: {
              normal: {
                barBorderRadius: 5,
                color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
                  { offset: 0, color: ColorList[index % ColorList.length][0] },
                  { offset: 1, color: ColorList[index % ColorList.length][1] }
                ])
              }
            },
            z: -12
          });
        });
      } else {
        // data[0].forEach((item, index) => {
        seriesData.push({
          name: "",
          type: "bar",
          data: [0],
          barWidth: 10,
          itemStyle: {
            normal: {
              barBorderRadius: 5,
              color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
                { offset: 0, color: "#04FA99" },
                { offset: 1, color: "#3EACE5" }
              ])
            }
          },
          z: -12
        });
        // })
      }
      this.cdatathree = {
        xAxisdata: data[2],
        xData: data[0],
        seriesData: seriesData,
        unitName: "次",
        rightShow: false
      };
    },
    // 填充表格空白行
    addblankmetone() {
      let havline = this.liaofeitableData.length % 6;
      if (this.liaofeitableData.length < 6) {
        if (havline < 6) {
          const remain = 6 - havline;
          for (var i = 0; i < remain; i++) {
            this.liaofeitableData.push({
              indflag: i + this.liaofeitableData.length - 1
            });
          }
        }
      }
    },
    // 设置生长作物模型是否展示
    setshowgrowmode() {
      let zhrouterlist = this.$store.state.permission.addRoutes;
      zhrouterlist.forEach(rouitem => {
        if (rouitem.routeId === 97) {
          rouitem.children.forEach(childitem => {
            if (childitem.routeId === 98) {
              this.isshowgrowmode = true;
            }
          });
        }
      });
    },
    // 跳转至生长作物模型
    tomgrowthodel() {
      // this.$router.push({ path: "/growth-data-monitor" })
      this.$router.push({ path: "/modelquery" });
    },
    // 获取种养总面积
    getTotalArea() {
      nowpagereq.getTotalArea().then(res => {
        if (res.data) {
          this.totalArea = res.data;
        }
      });
    },
    // 获取当前种养批次
    getAllBatch() {
      nowpagereq.getAllBatch().then(res => {
        this.allBatchList = res.data;
        // 循环获取种养类别表格，并去重
        let allbatchlistone = [];
        this.allBatchList.forEach(item => {
          let newname =
            (item.plantingTypeName || "") +
            (item.plantingTypeName && item.varietyName ? "-" : "") +
            (item.varietyName || "");
          let testindexof = allbatchlistone.indexOf(newname);
          if (testindexof === -1) {
            allbatchlistone.push(newname);
          }
        });
        this.allplanttypeone = allbatchlistone;
      });
    },
    // 申请其他基地
    shengqingjidi() {
      this.$confirm("暂未开放此功能，请联系管理员")
        .then(_ => {})
        .catch(_ => {});
    },
    // 当月告警信息-饼图
    getnowmonthalarmage() {
      let date = this.dateToFormatthree(new Date());
      let params = {
        endTime: `${date}-30 23:59:59` || "2021-12-01 01:01:01",
        startTime: `${date}-01 00:00:01` || "2020-12-01 01:01:01"
      };
      nowpagereq.getnowmonthalarmage(params).then(res => {
        // let addpie = [];
        let nowdatalist = res.data;
        this.nowdatalist = res.data;
        // nowdatalist.forEach(item => {
        //   let addvalue = { name: item.dataTypeName, value: item.number }
        //   addpie.push(addvalue)
        // });
        // if (addpie.length > 0) {
        this.$set(
          this.nowMonthTaskPietwo[0].data[0],
          "value",
          nowdatalist.pending
        );
        this.$set(
          this.nowMonthTaskPietwo[0].data[1],
          "value",
          nowdatalist.completed
        );
        this.$set(
          this.nowMonthTaskPietwo[0].data[2],
          "value",
          nowdatalist.overdue
        );
        // console.log()
        // this.nowMonthTaskPietwo[0].data[0] addpie
        // }
      });
    },
    async getnowmonthagriculturalTaskumber() {
      let date = this.dateToFormatthree(new Date());
      let params = {
        endTime: `${date}-30 23:59:59` || "2021-12-01 01:01:01",
        startTime: `${date}-01 00:00:01` || "2020-12-01 01:01:01"
      };
      // let resone = await nowpagereq.getalarmmessage({ ...params, disposeStatus: true })
      // this.alarmmessagenumone = resone.data.length
      // let restwo = await nowpagereq.getalarmmessage({ ...params, disposeStatus: false })
      // this.notalarmmessage = restwo.data
      // this.alarmmessagenumtwo = restwo.data.length
      let resthree = await nowpagereq.getagriculturalTasktwo({
        ...params,
        disposeStatus: false
      });
      this.notagriculturalTask = resthree?.data;
    },
    async getnowmonthalarmagenumber() {
      let date = this.dateToFormatthree(new Date());
      let params = {
        endTime: `${date}-30 23:59:59` || "2021-12-01 01:01:01",
        startTime: `${date}-01 00:00:01` || "2020-12-01 01:01:01"
      };
      // let resone = await nowpagereq.getalarmmessage({ ...params, disposeStatus: true })
      // this.alarmmessagenumone = resone.data.length
      // let restwo = await nowpagereq.getalarmmessage({ ...params, disposeStatus: false })
      // this.notalarmmessage = restwo.data
      // this.alarmmessagenumtwo = restwo.data.length
      let resthree = await nowpagereq.getalarmmessagetwo({
        ...params,
        disposeStatus: false
      });
      this.notalarmmessage = resthree.data.content;
    },
    // 当月任务-饼图
    getnowmonthfarmtaskpie() {
      nowpagereq.getnowmonthfarmtaskpie().then(res => {
        //  this.nowMonthTaskPie.
        let list = res.data;
        let newlist = [];
        if (list && list.length > 0) {
          list.forEach(item => {
            newlist.push({ name: item.name, value: item.number });
          });
          this.nowMonthTaskPie[0].data = newlist;
        }
      });
    },
    // 当月任务处理结果数量
    getnowmonthhandingtasknum() {
      nowpagereq.getnowmonthhandingtasknum().then(res => {
        this.nowMonthTasklist = res.data;
      });
    },
    // 获取批次告警次数
    // async getBatchAlarmNumber() {
    //   let res = await nowpagereq.getBatchAlarmNumber()
    //   let list = res.data
    //   // let xAxisdata = []
    //   // let messageStatisticsone = {
    //   //   name: '基础告警',
    //   //   type: 'bar',
    //   //   data: [],
    //   //   barWidth: 10,
    //   //   itemStyle: {
    //   //     // normal: {
    //   //     //   barBorderRadius: 5,
    //   //     //   color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
    //   //     //     { offset: 0, color: "#04FA99" },
    //   //     //     { offset: 1, color: "#3EACE5" }
    //   //     //   ])
    //   //     // }
    //   //   }
    //   // }
    //   // let messageStatisticstwo = {
    //   //   name: '手动告警',
    //   //   type: 'bar',
    //   //   data: [],
    //   //   barWidth: 10,
    //   //   itemStyle: {
    //   //     normal: {
    //   //       // barBorderRadius: 5,
    //   //       // color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
    //   //       //   { offset: 0, color: "#04FA99" },
    //   //       //   { offset: 1, color: "#3EACE5" }
    //   //       // ])
    //   //     }
    //   //   }
    //   // }
    //   // let messageStatisticsthree = {
    //   //   name: '设备异常告警',
    //   //   type: 'bar',
    //   //   data: [],
    //   //   barWidth: 10,
    //   //   itemStyle: {
    //   //     normal: {
    //   //       // barBorderRadius: 5,
    //   //       // color: new echarts.graphic.LinearGradient(1, 0, 0, 1, [
    //   //       //   { offset: 0, color: "#04FA99" },
    //   //       //   { offset: 1, color: "#3EACE5" }
    //   //       // ])
    //   //     }
    //   //   }
    //   // }
    //   list.forEach(
    //     item => {
    //       xAxisdata.push(item.time.substring(5, 10))
    //       messageStatisticsone.data.push(item.messageStatisticsList[0]['number'])
    //       messageStatisticstwo.data.push(item.messageStatisticsList[1]['number'])
    //       messageStatisticsthree.data.push(item.messageStatisticsList[2]['number'])
    //     }
    //   )
    //   let seriesData = [
    //     messageStatisticsone,
    //     messageStatisticstwo,
    //     messageStatisticsthree
    //   ]
    //   this.batchLineChart.xAxisdata = xAxisdata
    //   this.batchLineChart.seriesData = seriesData
    // },
    // 料肥统计下一页
    addliaofeipage() {
      let maxnum = this.liaofeipage * 10;
      if (this.liaofeitotal > maxnum) {
        this.liaofeipage += 1;
        this.getliaofeitableData();
      } else if (this.liaofeitotal <= maxnum) {
        this.$message.warning("已到最后一页");
      }
    },
    // 料肥统计上一页
    jianliaofeipage() {
      let minnum = this.liaofeipage - 1;
      if (minnum >= 1) {
        this.liaofeipage = minnum;
        this.getliaofeitableData();
      } else if (minnum < 1) {
        this.$message.warning("已到第一页");
      }
    },
    // 获取料肥统计表格
    getliaofeitableData() {
      let params = {
        page: this.liaofeipage,
        size: 10,
        entity: {
          medicinalFertilizerSign: true,
          organizationNo: sessionStorage.organizationNo
        }
      };
      nowpagereq.getliaofeilist(params).then(res => {
        this.liaofeitableData = res.data.content;
        this.liaofeitotal = res.data.totalElements;
        this.liaototalPages = res.data.totalPages;
        this.addblankmetone();
      });
    },
    liaofeiPasz(e) {
      if (e < 0) {
        this.liaofeipage = 1;
        this.getliaofeitableData();
      } else if (e > this.liaototalPages) {
        this.liaofeipage = this.liaototalPages;
        this.getliaofeitableData();
      } else if (typeof e !== Number) {
        // if (e)
        // this.liaofeipage = 1
        // this.getliaofeitableData()
      }
    },
    // 设置表格单位
    setunittable(id) {
      let name = "";
      this.unitlist.forEach(item => {
        if (item.unitId === id) {
          name = item.unitName;
        }
      });
      return name;
    },
    // 获取单位数组
    getunitlist() {
      // 获取单位选择框数据
      // danwei.getallunitlist().then((res) => {
      //   this.unitlist = res.data;
      // });
    },
    // 农事任务信息
    farmtaskdataechart() {
      nowpagereq.farmtaskdataechart().then(res => {
        let data = res.data;
        let xAxisone = [];
        if (data[0]) {
          xAxisone = data[0];
        }
        let addser = [];
        if (data[1]) {
          let listone = data[1];
          for (let zz in listone) {
            let addobj = {
              name: zz,
              type: "bar",
              data: listone[zz],
              barWidth: 10
            };
            addser.push(addobj);
          }
        }
        this.farmtaskcdata = {
          xAxisdata: xAxisone,
          xData: ["农事任务信息（近七天）"],
          seriesData: addser
        };
      });
    },
    // 农资投入
    farmsourceinputechart() {
      nowpagereq.farmsourceinputechart().then(res => {
        let data = res.data;
        let xAxisone = [];
        if (data[0]) {
          xAxisone = data[0];
        }
        let addser = [];
        if (data[1]) {
          let listone = data[1];
          for (let zz in listone) {
            let addobj = {
              name: zz,
              type: "bar",
              data: listone[zz],
              barWidth: 10
            };
            addser.push(addobj);
          }
        }
        this.farmsoucerecordcdata = {
          xAxisdata: xAxisone,
          xData: ["农资投入信息(近七天)"],
          seriesData: addser
        };
      });
    },
    // 获取任务告警信息
    getoldtasklist() {
      nowpagereq.getoldtasklist().then(res => {
        this.alarmtasknum = res.data[0].number;
      });
    },
    // 通过时间和批次表格数据
    gettablebatchList() {
      let params = {
        startTime: "2021-09-21 00:00:00",
        endTime: "2021-09-21 23:00:00"
      };
      if (this.tableSearchDateList[0]) {
        params.startTime = this.dateToFormat(this.tableSearchDateList[0]);
        params.endTime = this.dateToFormat(this.tableSearchDateList[1]);
      }
      // if (this.nowbatchId.length > 0) {
      params.batchNo = this.nowbatchId;
      // }
      nowpagereq.getalarmmessage(params).then(res => {
        // -----没查通
        this.batchAlarmTable = res.data;
        // console.log(res);
      });
    }
  }
};
</script>
<style lang="scss" scoped>
::v-deep {
  .liaoinput {
    width: 30px;
    height: 20px;
    border-radius: 2px;
    .el-input__inner {
      padding: 0 !important;
      border-radius: 2px;
      height: 20px;
      line-height: 20px;
      text-align: center;
    }
  }
}
.zhgrowthbut {
  width: 150px;
  padding-left: 15px;
  padding-right: 15px;
  font-size: 15px;
  display: flex;
  cursor: pointer;
  height: 35px;
  line-height: 35px;
  // border: 2px solid #cfdcdf;
  // background-image: linear-gradient(#0fa2d4,#0f88b1,#107192);
  background-image: url("../../assets/button-backsty/but1.png");
  background-repeat: no-repeat;
  background-size: 150px 35px;
  border-radius: 10px;
  white-space: nowrap;
}
.betterline {
  display: flex;
  width: 90%;
  overflow-x: auto;
  flex-wrap: wrap;
  max-height: 60px;
  // white-space: nowrap;
  .header-line-zh-item {
    // width: 300px;
    height: 40px;
    line-height: 40px;
    margin-top: 10px;
    white-space: nowrap;
    // font-size: 12px;
  }
}
.controlview-hearder {
  width: calc(100% - 10px);
  // margin-top:-10px;
  margin-left: 5px;
  // height: calc(100% - 700px);
  height: 160px;
  padding: 10px;
  // border: #fff 1px solid;
  background-color: #225768;
  margin-bottom: 10px;
  overflow: hidden;
  min-height: 60px;
  box-shadow: 0px 0px 5px 0px #00000090;
  border-radius: 2px;
  // display: flex;
  // flex-wrap: wrap;
  // justify-content: space-between;
  // align-items: center;
  .header-line-top {
    width: 100%;
    height: 40px;
    line-height: 40px;
    font-size: 16px;
    font-weight: 400;
    color: #64d9d6;
    border-bottom: #64d9d6 1px solid;
  }
  .header-line-main {
    width: 100%;
    height: 120px;
    display: flex;
    justify-content: space-around;
    align-items: center;
  }
  .header-line-one-zh {
    width: 170px;
    height: 90px;
    // border: #00ff2a 1px solid;
    display: flex;
    justify-content: space-around;
    align-items: center;
    white-space: nowrap;
    .zh-custom {
      height: 60px;
      width: 60px;
      font-size: 50px;
      color: #003947;
      background-color: #fff;
      border-radius: 50%;
      display: flex;
      justify-content: center;
      align-items: center;
    }
  }
  .header-line-right {
    width: calc(100% - 200px);
    height: 110px;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
  }
  .header-line-zh {
    width: calc(100% - 10px);
    height: 30px;
    display: flex;
    // justify-content: space-between;
    align-items: center;
    line-height: 30px;
    font-size: 18px;
    padding: 5px;
    //  white-space: nowrap;
    border-left: #fff 3px solid;
    // display: flex;
    // flex-wrap: wrap;
    // overflow: auto;
    // align-items: center;
    .header-line-zh-item {
      min-width: 100px;
      background-color: #0f4656;
      border-radius: 5px;
      margin-right: 20px;
      text-align: center;
      padding: 0 10px;
    }
    .addfarmcompany {
      width: 140px;
      height: 35px;
      cursor: pointer;
      white-space: nowrap;
      background-image: url("~@/assets/button-backsty/addcompany.png");
      background-repeat: no-repeat;
    }
  }
}
.controlview-main-one {
  width: calc(100% - 10px);
  margin-left: 5px;
  height: 1000px;
  // padding: 5px;
  // border: #fff 1px solid;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  .main-one-left {
    width: 500px;
    height: 1000px;
    // border: #fff 1px solid;
    display: flex;
    flex-direction: column;
    // justify-content: center;
    align-items: center;
    .one-left {
      box-shadow: 0px 0px 5px 0px #00000090;
      border-radius: 2px;
      width: 100%;
      height: 500px;
      margin-bottom: 10px;
      box-sizing: border-box;
      background-color: #225768;
      padding: 10px;
    }
    .one-left-title {
      width: 100%;
      height: 50px;
      margin-bottom: 10px;
      font-size: 16px;
      line-height: 50px;
      padding-left: 10px;
      border-bottom: #64d9d6 1px solid;
      color: #64d9d6;

      font-weight: 400;
    }
    .one-left-menu {
      width: 100%;
      height: 400px;
      overflow-y: auto;
      overflow-x: hidden;
      border: #64d9d6 1px solid;
      .left-menu-item {
        width: 100%;
        min-height: 70px;
        // overflow-y: auto;
        border: #64d9d6 1px solid;
        display: flex;
        align-items: center;
        .menu-item-title {
          width: 140px;
          color: #7cdcf5;
          font-weight: 600;
          height: 30px;
          line-height: 30px;
          margin-left: 5px;
          white-space: nowrap;
        }
        .menu-item-title-two {
          width: 108px;
          color: #7cdcf5;
          font-weight: 600;
          height: 30px;
          line-height: 30px;
          margin-left: 5px;
          white-space: nowrap;
        }
        .menu-item-message {
          overflow-y: hidden;
          line-height: 24px;
          padding: 3px 20px;
        }
      }
      .left-menu-item:nth-child(2n - 1) {
        background-color: #146078;
      }
      .left-menu-item:nth-child(2n) {
        background-color: #225768;
      }
    }
  }
  .main-one-right {
    width: calc(100% - 510px);
    height: 1000px;
    display: flex;
    flex-direction: column;
    // justify-content: center;
    align-items: center;
    // display: flex;
    .one-right-line {
      width: 100%;
      height: 490px;
      margin-bottom: 10px;
      background-color: #225768;
      box-shadow: 0px 0px 5px 0px #00000090;
      border-radius: 2px;
      display: flex;
      box-sizing: border-box;
      flex-wrap: wrap;
      padding: 10px;
      &:last-child {
        margin-bottom: 0px;
      }
      .right-line-title {
        width: 100%;
        height: 50px;
        line-height: 44px;
        font-size: 16px;
        text-align: left;
        padding-left: 10px;
        color: #64d9d6;
        border-bottom: #64d9d6 1px solid;
        font-weight: 400;
      }
      .zh-pie {
        width: 100%;
        height: 328px;
      }
      .right-line-main {
        width: 100%;
        height: 40px;
        padding: 5px;
        display: flex;
        flex-wrap: nowrap;
        align-items: flex-start;
        justify-content: flex-start;
        padding: 5px;
        overflow: auto;
        position: relative;
        .line-main-one {
          width: 15%;
          min-width: 5%;
          // min-width: 100px;
          display: flex;
          // height: 150px;
          .line-main-one-title {
            width: 100%;
            // min-width: 100px;
            height: 30px;
            line-height: 30px;
            // border-bottom: 1px solid #fff;
            font-size: 12px;
            font-weight: 600;
            text-align: center;
            margin-right: 10px;
          }
          .line-main-one-message {
            width: 100%;
            // min-width: 100px;
            // height: 100px;
            display: flex;
            justify-content: center;
            align-items: center;
            font-size: 22px;
          }
        }
        // .zh-back {
        // background-color: #256899;
        // }
        // .zh-backtwo {
        // background-color: #1a8b92;
        // }
        // .zh-backthree {
        // background-color: #93996e;
        // }
      }
    }
  }
}
.controlview-main-two {
  width: calc(100% - 10px);
  box-shadow: 0px 0px 5px 0px #00000090;
  min-height: 200px;
  border-radius: 2px;
  padding: 10px;
  margin-left: 5px;
  // border: #d8dfd9 1px solid;
  background-color: #225768;
  .controlview-main-two-hearder {
    width: 100%;
    height: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    // border-bottom: #93adb6 1px solid;
    border-bottom: #64d9d6 1px solid;

    margin-bottom: 5px;
    padding-bottom: 5px;
    .main-two-hearder-title {
      // color: #fff;
      height: 30px;
      line-height: 30px;
      padding-left: 10px;
      font-weight: 400;
      font-size: 16px;
      color: #64d9d6;
    }
    .main-two-hearder-right {
      color: #fff;
      background-color: #0fbbf2;
      border-radius: 10px;
      width: 80px;
      height: 25px;
      line-height: 25px;
      text-align: center;
      font-weight: 600;
      cursor: pointer;
    }
  }
  .main-two-echart-line {
    width: 100%;
    height: 160px;
  }
  .main-two-table-line {
    width: 100%;
    height: 540px;
    .tab-fac {
      margin-right: 5px;
      margin-left: 5px;
    }
  }
}
.controlview-main-three {
  width: calc(100% - 10px);
  // box-shadow: 0px 0px 5px 0px #00000090;
  height: 330px;
  min-height: 200px;
  border-radius: 2px;
  // padding: 10px;
  margin-left: 5px;
  > div {
    height: 100%;
  }
  .main-two-yiban-box {
    width: 49.5%;
    // height: 300px;
    height: 100%;

    box-shadow: 0px 0px 5px 0px #00000090;
    background-color: #225768;
    padding: 10px;
    &:first-child {
      margin-right: 1%;
    }
    .main-two-hearder-title {
      // color: #fff;
      height: 30px;
      line-height: 30px;
      padding-left: 10px;
      font-weight: 400;
      font-size: 16px;
      color: #64d9d6;
      border-bottom: #64d9d6 1px solid;
    }
  }
}
::v-deep .el-dialog {
  width: 100%;
  height: 700px;
  background-color: #005d7b;
  border: #23fff8 1px solid;
  color: #fff;
  .el-input__inner {
    color: #fff !important;
  }
  .el-dialog__title {
    color: #fff;
  }
  .zh-table {
    width: 100%;
    height: 700px;
    color: #fff;
    .zh-table-search {
      width: 100%;
      height: 50px;
      display: flex;
      align-items: center;
      .contrl-view-but {
        width: 100px;
        height: 45px;
        line-height: 45px;
        background-size: 80px 40px;
        background-repeat: no-repeat;
        background-position: center;
        background-image: url("../../assets/action-bar-icon/search.png");
        cursor: pointer;
      }
    }
  }
}
</style>
